<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>Title</title>
</head>
<style>
    div{
        width: 250px;
        margin: 0 auto;
    }
    h2{
        text-align: center;
    }
    #res{
        position: relative;
        left: 100px;
    }
</style>
<script src="<%=request.getContextPath() %>../resources/js/jquery-3.1.1.js" type="text/javascript"></script>

<body>
   <div>
       <h2>用户注册</h2>
       <form action="registerServlet" method="post">
           用户：<input type="text" name="username" id="username"/><span id="checkResult" style="color: darkred"></span><br/>
           密码：<input type="password" name="pwd" id="pwd"/><br/><br/>
           <input id="res" type="submit" value="注册"/>
       </form>
   </div>

<script>
    $(function () {
        $("#username").blur(function () {
            var adminname = $("#username").val();
            $.ajax({
                url: 'checkAdminNameServlet',
                type: 'POST',
                data: {
                    'adminName': adminname
                },
                success: function (result) {
                    $("#checkResult").text(result);
                }
            });
        });
    });
</script>
</body>
</html>